Attribute VB_Name = "Module1"
Public adoConnection As New ADODB.Connection
Public Sub KetNoi()
On Error GoTo Errp
Dim strPath As String
    strPath = GetAutoticketingDBPath
    
    If adoConnection.State = adStateOpen Then adoConnection.Close
    adoConnection.CursorLocation = adUseClient
    If Trim(strPath) = "" Then
        adoConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\db.mdb"
    Else
        adoConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strPath
    End If
    'MsgBox " Access the Database successful !", vbInformation + vbOKOnly, "Access"
    Exit Sub
Errp:
    MsgBox Err.Description
End Sub

 Public Function GetAutoticketingDBPath() As String
 Dim strLine As String
 If Dir(App.Path & "\datapath.ini") = "" Then
    GetAutoticketingDBPath = ""
    Exit Function
 End If
 Open App.Path & "\datapath.ini" For Input As #1
    Line Input #1, strLine
    Close #1
  GetAutoticketingDBPath = strLine
End Function


Public Function DisconnectDB()
        If Not adoConnection Is Nothing Then
            If adoConnection.State = adStateOpen Then
                adoConnection.Close
            End If
            Set adoConnection = Nothing
        End If
End Function
